namespace CarterWechatServer.DataEntity.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Add_Order : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.OrderInfo",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderId = c.Int(nullable: false),
                        DishId = c.Int(nullable: false),
                        Count = c.Int(nullable: false),
                        Amount = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Dish", t => t.DishId, cascadeDelete: true)
                .ForeignKey("dbo.Order", t => t.OrderId, cascadeDelete: true)
                .Index(t => t.OrderId)
                .Index(t => t.DishId);
            
            CreateTable(
                "dbo.Order",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderTime = c.DateTime(nullable: false),
                        UserId = c.Int(nullable: false),
                        TotalCount = c.Int(nullable: false),
                        TotalAmount = c.Int(nullable: false),
                        OrderStatus = c.Int(nullable: false),
                        OrderCode = c.String(),
                        WechatOrderCode = c.String(),
                        TakeNo = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.User", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.OrderInfo", "OrderId", "dbo.Order");
            DropForeignKey("dbo.Order", "UserId", "dbo.User");
            DropForeignKey("dbo.OrderInfo", "DishId", "dbo.Dish");
            DropIndex("dbo.Order", new[] { "UserId" });
            DropIndex("dbo.OrderInfo", new[] { "DishId" });
            DropIndex("dbo.OrderInfo", new[] { "OrderId" });
            DropTable("dbo.Order");
            DropTable("dbo.OrderInfo");
        }
    }
}
